/*
               File: C52
        Description: Conversion for table MMMDA10
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 14:36:59.38
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c52 extends GXProcedure
{
   public c52( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c52.class ), "" );
   }

   public c52( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C522 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A189MarCod = C522_A189MarCod[0] ;
         A392ModUUM = C522_A392ModUUM[0] ;
         A391ModHUM = C522_A391ModHUM[0] ;
         A390ModFUM = C522_A390ModFUM[0] ;
         A389ModUCR = C522_A389ModUCR[0] ;
         A388ModHCR = C522_A388ModHCR[0] ;
         A387ModFCR = C522_A387ModFCR[0] ;
         A592ModEst = C522_A592ModEst[0] ;
         A386ModNom = C522_A386ModNom[0] ;
         A385ModCod = C522_A385ModCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0052

         */
         AV2ModCod = A385ModCod ;
         if ( C522_n386ModNom[0] )
         {
            AV3ModNom = "" ;
         }
         else
         {
            AV3ModNom = A386ModNom ;
         }
         if ( C522_n592ModEst[0] )
         {
            AV4ModEst = "" ;
         }
         else
         {
            AV4ModEst = A592ModEst ;
         }
         if ( C522_n387ModFCR[0] )
         {
            AV5ModFCR = GXutil.nullDate() ;
         }
         else
         {
            AV5ModFCR = A387ModFCR ;
         }
         if ( C522_n388ModHCR[0] )
         {
            AV6ModHCR = "" ;
         }
         else
         {
            AV6ModHCR = A388ModHCR ;
         }
         if ( C522_n389ModUCR[0] )
         {
            AV7ModUCR = "" ;
         }
         else
         {
            AV7ModUCR = A389ModUCR ;
         }
         if ( C522_n390ModFUM[0] )
         {
            AV8ModFUM = GXutil.nullDate() ;
         }
         else
         {
            AV8ModFUM = A390ModFUM ;
         }
         if ( C522_n391ModHUM[0] )
         {
            AV9ModHUM = "" ;
         }
         else
         {
            AV9ModHUM = A391ModHUM ;
         }
         if ( C522_n392ModUUM[0] )
         {
            AV10ModUUM = "" ;
         }
         else
         {
            AV10ModUUM = A392ModUUM ;
         }
         AV11MarCod = A189MarCod ;
         /* Using cursor C523 */
         pr_default.execute(1, new Object[] {AV2ModCod, AV3ModNom, AV4ModEst, AV5ModFCR, AV6ModHCR, AV7ModUCR, AV8ModFUM, AV9ModHUM, AV10ModUUM, AV11MarCod});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C522_A189MarCod = new String[] {""} ;
      C522_A392ModUUM = new String[] {""} ;
      C522_A391ModHUM = new String[] {""} ;
      C522_A390ModFUM = new java.util.Date[] {GXutil.nullDate()} ;
      C522_A389ModUCR = new String[] {""} ;
      C522_A388ModHCR = new String[] {""} ;
      C522_A387ModFCR = new java.util.Date[] {GXutil.nullDate()} ;
      C522_A592ModEst = new String[] {""} ;
      C522_A386ModNom = new String[] {""} ;
      C522_A385ModCod = new String[] {""} ;
      A189MarCod = "" ;
      A392ModUUM = "" ;
      A391ModHUM = "" ;
      A390ModFUM = GXutil.nullDate() ;
      A389ModUCR = "" ;
      A388ModHCR = "" ;
      A387ModFCR = GXutil.nullDate() ;
      A592ModEst = "" ;
      A386ModNom = "" ;
      A385ModCod = "" ;
      GIGXA0052 = 0 ;
      AV2ModCod = "" ;
      C522_n386ModNom = new boolean[] {false} ;
      AV3ModNom = "" ;
      C522_n592ModEst = new boolean[] {false} ;
      AV4ModEst = "" ;
      C522_n387ModFCR = new boolean[] {false} ;
      AV5ModFCR = GXutil.nullDate() ;
      C522_n388ModHCR = new boolean[] {false} ;
      AV6ModHCR = "" ;
      C522_n389ModUCR = new boolean[] {false} ;
      AV7ModUCR = "" ;
      C522_n390ModFUM = new boolean[] {false} ;
      AV8ModFUM = GXutil.nullDate() ;
      C522_n391ModHUM = new boolean[] {false} ;
      AV9ModHUM = "" ;
      C522_n392ModUUM = new boolean[] {false} ;
      AV10ModUUM = "" ;
      AV11MarCod = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c52__default(),
         new Object[] {
             new Object[] {
            C522_A189MarCod, C522_A392ModUUM, C522_n392ModUUM, C522_A391ModHUM, C522_n391ModHUM, C522_A390ModFUM, C522_n390ModFUM, C522_A389ModUCR, C522_n389ModUCR, C522_A388ModHCR,
            C522_n388ModHCR, C522_A387ModFCR, C522_n387ModFCR, C522_A592ModEst, C522_n592ModEst, C522_A386ModNom, C522_n386ModNom, C522_A385ModCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short Gx_err ;
   private int GIGXA0052 ;
   private String A189MarCod ;
   private String A392ModUUM ;
   private String A391ModHUM ;
   private String A389ModUCR ;
   private String A388ModHCR ;
   private String A592ModEst ;
   private String A386ModNom ;
   private String A385ModCod ;
   private String AV2ModCod ;
   private String AV3ModNom ;
   private String AV4ModEst ;
   private String AV6ModHCR ;
   private String AV7ModUCR ;
   private String AV9ModHUM ;
   private String AV10ModUUM ;
   private String AV11MarCod ;
   private String Gx_emsg ;
   private java.util.Date A390ModFUM ;
   private java.util.Date A387ModFCR ;
   private java.util.Date AV5ModFCR ;
   private java.util.Date AV8ModFUM ;
   private IDataStoreProvider pr_default ;
   private String[] C522_A189MarCod ;
   private String[] C522_A392ModUUM ;
   private String[] C522_A391ModHUM ;
   private java.util.Date[] C522_A390ModFUM ;
   private String[] C522_A389ModUCR ;
   private String[] C522_A388ModHCR ;
   private java.util.Date[] C522_A387ModFCR ;
   private String[] C522_A592ModEst ;
   private String[] C522_A386ModNom ;
   private String[] C522_A385ModCod ;
   private boolean[] C522_n386ModNom ;
   private boolean[] C522_n592ModEst ;
   private boolean[] C522_n387ModFCR ;
   private boolean[] C522_n388ModHCR ;
   private boolean[] C522_n389ModUCR ;
   private boolean[] C522_n390ModFUM ;
   private boolean[] C522_n391ModHUM ;
   private boolean[] C522_n392ModUUM ;
}

final class c52__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C522", "SELECT [MarCod], [ModUUM], [ModHUM], [ModFUM], [ModUCR], [ModHCR], [ModFCR], [ModEst], [ModNom], [ModCod] FROM [MMMDA10] WITH (NOLOCK) ORDER BY [MarCod], [ModCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C523", "INSERT INTO [GXA0052] ([ModCod], [ModNom], [ModEst], [ModFCR], [ModHCR], [ModUCR], [ModFUM], [ModHUM], [ModUUM], [MarCodAux]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((String[]) buf[1])[0] = rslt.getString(2, 10) ;
               ((boolean[]) buf[2])[0] = rslt.wasNull();
               ((String[]) buf[3])[0] = rslt.getString(3, 8) ;
               ((boolean[]) buf[4])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[5])[0] = rslt.getGXDate(4) ;
               ((boolean[]) buf[6])[0] = rslt.wasNull();
               ((String[]) buf[7])[0] = rslt.getString(5, 10) ;
               ((boolean[]) buf[8])[0] = rslt.wasNull();
               ((String[]) buf[9])[0] = rslt.getString(6, 8) ;
               ((boolean[]) buf[10])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[11])[0] = rslt.getGXDate(7) ;
               ((boolean[]) buf[12])[0] = rslt.wasNull();
               ((String[]) buf[13])[0] = rslt.getString(8, 1) ;
               ((boolean[]) buf[14])[0] = rslt.wasNull();
               ((String[]) buf[15])[0] = rslt.getString(9, 50) ;
               ((boolean[]) buf[16])[0] = rslt.wasNull();
               ((String[]) buf[17])[0] = rslt.getString(10, 10) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setString(2, (String)parms[1], 50);
               stmt.setString(3, (String)parms[2], 1);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setString(6, (String)parms[5], 10);
               stmt.setDate(7, (java.util.Date)parms[6]);
               stmt.setString(8, (String)parms[7], 8);
               stmt.setString(9, (String)parms[8], 10);
               stmt.setString(10, (String)parms[9], 10);
               break;
      }
   }

}

